<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
    <link rel="stylesheet" href="../static/layui/css/layui.css">
    <script src="../static/layui/layui.js"></script>
    <!--     <script type="text/javascript">try { Typekit.load(); } catch (e) { }</script> -->
    <script type="text/javascript" src="../static/js/tool_p.js"></script>
</head>
<body>

<div class="layui-form-item" style="text-align: center;margin-top: 100px">
    <label class="layui-form-label">接口id</label>
    <div class="layui-input-block">
        <input type="text" name="title" id="id" lay-verify="title" autocomplete="off" placeholder="请输入接口id"
               class="layui-input"
               style="width: 200px">
    </div>
    <br>
    <br>
    <button type="button" class="layui-btn" onclick="open_monitor()">开启监控</button>
    <button type="button" class="layui-btn" onclick="stop_monitor()">停止监控</button>
    <br>
    <br>
    <button type="button" class="layui-btn" onclick="open_notice()">开启通知</button>
    <button type="button" class="layui-btn" onclick="stop_notice()">停止通知</button>
    <br>
    <br>
    <button type="button" class="layui-btn" onclick="status()">查询接口状态</button>
</div>
</body>
<script>
    function open_monitor() {
        var id = document.getElementById("id").value
        if (id == "") {
            alert("请输入接口id")
        }
        var xmlhttp;
        xmlhttp = new XMLHttpRequest();
        xmlhttp.open("POST", "switch", true);
        var params = 'type=monitor&id=' + id + '&val=1';
        xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        xmlhttp.send(params);
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                var c = xmlhttp.responseText
                alert(c)
            }
        }
    }

    function stop_monitor() {
        var id = document.getElementById("id").value
        if (id == "") {
            alert("请输入接口id")
        }
        var xmlhttp;
        xmlhttp = new XMLHttpRequest();
        xmlhttp.open("POST", "switch", true);
        var params = 'type=monitor&id=' + id + '&val=0';
        xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        xmlhttp.send(params);
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                var c = xmlhttp.responseText
                alert(c)
            }
        }
    }

    function open_notice() {
        var id = document.getElementById("id").value
        if (id == "") {
            alert("请输入接口id")
        }
        var xmlhttp;
        xmlhttp = new XMLHttpRequest();
        xmlhttp.open("POST", "switch", true);
        var params = 'type=notice&id=' + id + '&val=1';
        xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        xmlhttp.send(params);
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                var c = xmlhttp.responseText
                alert(c)
            }
        }
    }

    function stop_notice() {
        var id = document.getElementById("id").value
        if (id == "") {
            alert("请输入接口id")
        }
        var xmlhttp;
        xmlhttp = new XMLHttpRequest();
        xmlhttp.open("POST", "switch", true);
        var params = 'type=notice&id=' + id + '&val=0';
        xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        xmlhttp.send(params);
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                var c = xmlhttp.responseText
                alert(c)
            }
        }
    }

    function status() {
        var id = document.getElementById("id").value;
        if (id == "") {
            alert("请输入接口id")
        }
        var xmlhttp;
        xmlhttp = new XMLHttpRequest();
        xmlhttp.open("POST", "switch", true);
        var params = 'type=status&id=' + id + '&val=0';
        xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        xmlhttp.send(params);
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                var c = xmlhttp.responseText
                alert(c)
            }
        }
    }
</script>
</html>
